package com.onlyxiahui.extend.query.hibernate.handler.result.config;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import org.springframework.core.convert.converter.Converter;

/**
 * Description <br>
 * Date 2019-05-21 14:51:31<br>
 * 
 * @author XiaHui [onlovexiahui@qq.com]<br>
 * @since 1.0.0
 */

public class LocalDateTimeDeserializerConverter implements Converter<String, LocalDateTime> {

	@Override
	public LocalDateTime convert(String text) {
		LocalDateTime localDateTime = null;
		if (null != text && !text.isEmpty()) {
			text = DateTimeUtil.allToDateTimeMillisecond(text);
			DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateTimeUtil.FORMAT_DATE_TIME_MILLISECOND);
			localDateTime = LocalDateTime.parse(text, formatter);
		}
		return localDateTime;
	}
}
